package priv.wangy.micro.common.utils.json.serialize;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import priv.wangy.micro.common.utils.EncryptUtil;

import java.io.IOException;

/**
 * @author zhangjq
 * @since 2024-09-27
 */
public class CstmJacksonDecryptHandler extends JsonSerializer<String> {

    @Override
    public void serialize(String value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String plain = EncryptUtil.decrypt(value);
        jsonGenerator.writeString(plain);
    }
}
